﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            Test5();
        }
        public static void Test()
        {
            Console.WriteLine("请输入正方形的边长");
            int r = int.Parse(Console.ReadLine());
            string[,] arr = new string[r, r];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i, j] = "*"+" ";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i,j]);
                }
                Console.WriteLine();
            }
                
            
        }
        //打印九九乘法表
        public static void Test1()
        {
            string[,] arr = new string[9, 9];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    arr[i, j] = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1) + "\t";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();

            }


        }
        //用户输入正方形边长，用* 打印出空心正方形。
        public static void Test2()
        {
            Console.WriteLine("请输入正方形的边长");
            int r = int.Parse(Console.ReadLine());
            string[,] arr = new string[r, r];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i,j]= "*";
                }
            }
            for (int i = 0; i <arr.GetLength(0); i++)
            {
                for (int j= 0; j < arr.GetLength(1); j++)
                {
                    if (j == 0 || i == 0 || j == arr.GetLength(1) - 1 || i == arr.GetLength(0) - 1)
                    {
                        Console.Write(arr[i, j]);
                    }
                    else {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        //打印菱形
        public static void Test3()
        {
            for (int i = 1; i <= 5; i++)
            {
                for (int j = 1; j <= 5 - i; j++)
                {
                    Console.Write(" ");
                }
                for (int k = 1; k <= 2 * i - 1; k++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            for (int i = 1; i <= 4; i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(" ");
                }
                for (int k = 7; k >= 2 * i - 1; k--)
                {
                    Console.Write("*");

                }
                Console.WriteLine();
            }

        }
        //如果一个数组保存元素是有序的（从大到小），
        //向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。

        public static void Test4()
        {
            int temp;
            int[] arr = { 20, 15, 10, 5,2 };
            Console.WriteLine("请输入一个数字");
            int number = int.Parse(Console.ReadLine());
            for (int i = 0; i < arr.Length; i++)
            {
                if (number < arr[i])
                {
                    continue;
                }else
                {
                    temp = arr[i];
                    arr[i] = number;
                    number = temp;
                }
            }
            Console.WriteLine("加入数字后数组的排序：");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i]+"|");
            }
            


        }
        //并存入 5 个值，然后将数组中下标是偶数的元素输出。
        public static void Test5()
        {
            string [] arr = { "10","2","50","46","12" };
            for (int i = 0; i < arr.Length;i+=2)
            {
                Console.WriteLine(arr[i]);
            }
            
        }
        //打印杨辉三角形（要求打印10行），如下所示：（使用二维数组）
        public static void Test6()
        {
            string[,] a = new string[10, 10];
            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j <a.GetLength(1); j++)
                {

                }
            }
        }
    }
}
